package com.googlecode.utterlyidle.multipart;

public class ContentDisposition {
    private String name;
    private String filename;

    public ContentDisposition(String name) {
        this.name = name;
    }

    public ContentDisposition(String name, String filename) {
        this.name = name;
        this.filename = filename;
    }

    public static ContentDisposition contentDisposition(String name) {
        return new ContentDisposition(name);
    }

    public static ContentDisposition contentDisposition(String name, String filename) {
        return new ContentDisposition(name, filename);
    }

    @Override
    public String toString() {
        String basic = String.format("form-data; name=\"%s\"", name);
        return filename == null ? basic : basic + "; " + String.format("filename=\"%s\"", filename);
    }
}
